﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Transactions;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.Base.Service
{
    public class BranchManageInfoService
    {
        readonly BranchManageInfoDao manageInfoDao = new BranchManageInfoDao();
        /// <summary>
        /// 根据产品版本ID获取子系统与模块
        /// </summary>
        public List<CommonTree> GetProductModules(string productVersionID)
        {
            return manageInfoDao.GetProductModules(productVersionID);
        }
        /// <summary>
        /// 根据产品ID获取产品版本列表
        /// </summary>
        public List<CommonEntity> GetProductVersions(string productID)
        {
            return manageInfoDao.GetProductVersions(productID);
        }
        /// <summary>
        /// 根据产品版本、子系统和模块获取新的版本下的信息
        /// </summary>
        public Dictionary<string, object> GetBranchManageInfo(string productVersionID, string subSystemCode, string moduleCode)
        {
            Dictionary<string, object> res = new Dictionary<string, object>();
            try
            {
                var manageInfo = manageInfoDao.GetBranchManageInfo(productVersionID, subSystemCode, moduleCode);
                res["state"] = "1";
                res["data"] = manageInfo;
            }
            catch (Exception e)
            {
                res["state"] = "0";
                res["errmsg"] = e.ToString();
            }
            return res;
        }
    }
}
